
angular.module('U9ImHd.controllers')

.controller('LoginCtrl', ['$scope', '$ionicHistory', '$state', 'User', function ($scope, $ionicHistory, $state, User) {
    $scope.data = {
        activeIndex: 1,
        usercode: '',
        password: '',
        autologin: false
    };

    $scope.clickTab = function (index) {
        $scope.data.activeIndex = index;
    };
    $scope.signin = function () {
        User.signin(
            $scope.data.usercode, 
            $scope.data.password, 
            $scope.data.autologin
        ).then(function () {
            $ionicHistory.nextViewOptions({
                historyRoot: true,
                disableAnimate: true,
                expire: 300
            });
            $state.go('home');
        });
    };
}]);